function allReadyEdit() {
    curToolbar.get('addrow').setDisabled(true);
    if (otype == 'add' || otype == 'copy') {
        NG.setAllColumnVisible();
        NG.getItem('pca').setVisible(true);
        NG.getItem('gcxmb').setVisible(false);
    }
    var zjhbh_label = NG.getItem('zjhbh').el.query('label')[0];
    zjhbh_label.style.width = '';
    zjhbh_label.parentElement.width = '130px';
    NG.getItem('bglx').on('helpselected', function (p1) {
        NG._getGrid().getStore().removeAll();
        NG.setValue('pc', null);
        NG.setValue('pca', null);
        NG.setValue('gcxmb', null);
        NG.setValue('zjhbh', '');
        if (p1.code == '1') {
            NG._getGrid().hideColumn('sbmc_name', true);
            NG._getGrid().hideColumn('sbmc1', false);
            NG.getItem('pca').setVisible(false);
            NG.getItem('gcxmb').setVisible(true);
            curToolbar.get('addrow').setDisabled(true);
        } else if (p1.code == '2') {
            NG._getGrid().hideColumn('sbmc1', true);
            NG._getGrid().hideColumn('sbmc_name', false);
            NG.getItem('pca').setVisible(true);
            NG.getItem('gcxmb').setVisible(false);
            curToolbar.get('addrow').setDisabled(false);
        }
    });
    NG.getItem('pca').on('helpselected', function (p1) {
        if (p1) {
            NG.setValue('pc', p1.data.phid);
            var v_zjhbh = NG.callServer('需求总计划编号', {pc: p1.data.phid}, 'bill_no');
            if (v_zjhbh) {
                NG.setValue('zjhbh', v_zjhbh);
            }
        }
    });
    NG.getItem('gcxmb').on('helpselected', function (p1) {
        if (p1) {
            NG.setValue('pc', p1.data.phid);
            var v_zjhbh = NG.callServer('需求总计划编号', {pc: p1.data.phid}, 'bill_no');
            if (v_zjhbh) {
                NG.setValue('zjhbh', v_zjhbh);
            }
            NG.addDetailBySql('原计划项目物料', {'pc': p1.data.phid}, true);
        }
    });

    NG._getGrid().getColumn('sbmc_name').getEditor().on('helpselected', function (record) {
        var curRow = NG._getGrid().getSelectionModel().getSelection()[0];
        if (curRow) {
            curRow.data.sbbh = record.data.itemno;
            curRow.data.gg = record.data.spec;
            curRow.data.msunit = record.data.phid_msunit;
            curRow.data.msunit_name = record.data.msname;
            curRow.data.phid_itemdata = record.data.phid;
            NG._getGrid().getView().refresh();
        }
    });

    NG._getGrid().getColumn('bghsl').getEditor().on('change', function (p1, p2) {
        var curRow = NG._getGrid().getSelectionModel().getSelection()[0];
        if (curRow) {
            curRow.data.bgsl = (p2 || 0) - (curRow.data.qty || 0);
            NG._getGrid().getView().refresh();
        }
    });
}
